/*
 * Urgência.java
 *
 * Created on 26 de Janeiro de 2009, 19:22
 */

package cadastros;

import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import utilitarios.conexao;

/**
 *
 * @author  Shinigami
 */
public class tecnico extends javax.swing.JFrame {

    /** Creates new form Urgência */
    conexao con_server, con_servf, con_aberto, con_pesq, con_atual, con_ordem, con_tec;
    int ordem, ord;
    
    public tecnico() {
        initComponents();
    
    con_atual = new conexao();
    con_atual.conecta();
    
    con_ordem = new conexao();
    con_ordem.conecta();
    
    con_tec = new conexao();
    con_tec.conecta();
    
    lb_codcall.setVisible(false);
    
   
      
    
    
    try {
            
            con_tec.executasql("select * from login where acesso like 'ADMINISTRADOR'");
            con_tec.resultset.beforeFirst();
            
            while(con_tec.resultset.next())
            {  
                cb_tec.addItem(con_tec.resultset.getString("nome"));
                
            }
        } catch (SQLException ex) {
            
        }
        
    
    
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        cb_tec = new javax.swing.JComboBox();
        bt_tec = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        lb_codcall = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setTitle("Técnicos");
        setResizable(false);

        jLabel1.setText("Selecione o novo responsável pelo chamado:");

        cb_tec.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "" }));

        bt_tec.setIcon(new javax.swing.ImageIcon(getClass().getResource("/imagens/dialog-apply.png"))); // NOI18N
        bt_tec.setToolTipText("OK");
        bt_tec.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_tecActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(cb_tec, javax.swing.GroupLayout.Alignment.LEADING, 0, 215, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGap(83, 83, 83)
                        .addComponent(bt_tec, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel2)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 36, Short.MAX_VALUE)
                        .addComponent(lb_codcall, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(33, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(20, 20, 20)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(cb_tec, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(18, 18, 18)
                        .addComponent(lb_codcall, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(bt_tec, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(23, Short.MAX_VALUE))
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-266)/2, (screenSize.height-171)/2, 266, 171);
    }// </editor-fold>//GEN-END:initComponents

private void bt_tecActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_tecActionPerformed

    try
    {
            
                    
            String codcall = hd_server.lb_ncall.getText();
                   
   
            String qsql = "UPDATE helpdeska SET tecnico ='"+cb_tec.getSelectedItem()+"'Where codcalla ="+codcall;
            con_atual.executasql("select * from helpdeska where codcalla="+codcall); 
            con_atual.resultset.first();
            con_atual.statement.executeUpdate(qsql);    
            
            
            //hd_principal.con_hdserver.executasql("select * from helpdeska where codcalla="+codcall);
            hd_principal.con_hdserver.executasql("select * from helpdeska");
            hd_principal.con_hdserver.resultset.beforeFirst();
            //new hd_server().setVisible(true);
            while(hd_principal.con_hdserver.resultset.next())
            {
                if(hd_principal.con_hdserver.resultset.getString("codcalla").equals(codcall))
                {
                 hd_server.mostrar_dados();
                 break;
                }
                else
                {
                    continue;
                }
            }
            
            
            
            /*hd_server.lb_status.setText(con_aberto.resultset.getString("status"));
            hd_server.lb_tecresp.setText(con_aberto.resultset.getString("tecnicoa"));
            hd_server.lb_urg.setText(con_aberto.resultset.getString("urgenciaa"));*/
            
           
    
    }
    catch (SQLException ex) {
            Logger.getLogger(hd_principal.class.getName()).log(Level.SEVERE, null, ex);
        }
    
    setVisible(false);
}//GEN-LAST:event_bt_tecActionPerformed

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new tecnico().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton bt_tec;
    private javax.swing.JComboBox cb_tec;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    public static javax.swing.JLabel lb_codcall;
    // End of variables declaration//GEN-END:variables

}
